﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SP.SPProjects.WebParts.Model
{
    public partial class DataContext : Microsoft.SharePoint.Linq.DataContext
    {

	
	#region Extensibility Method Definitions
	partial void OnCreated();
	#endregion

    public DataContext(string requestUrl) : 
			base(requestUrl) {
		this.OnCreated();
	}
	
	/// <summary>
	/// List for project tasks
	/// </summary>
	[Microsoft.SharePoint.Linq.ListAttribute(Name="Tasks")]
	public Microsoft.SharePoint.Linq.EntityList<TasksBaseTask> Tasks {
		get {
			return this.GetList<TasksBaseTask>("Tasks");
		}
	}
}

/// <summary>
/// Create a new list item.
/// </summary>
[Microsoft.SharePoint.Linq.ContentTypeAttribute(Name="Item", Id="0x01")]
[Microsoft.SharePoint.Linq.DerivedEntityClassAttribute(Type=typeof(Task))]
public partial class Item : Microsoft.SharePoint.Linq.ITrackEntityState, Microsoft.SharePoint.Linq.ITrackOriginalValues, System.ComponentModel.INotifyPropertyChanged, System.ComponentModel.INotifyPropertyChanging {
	
	private System.Nullable<int> _id;
	
	private System.Nullable<int> _version;
	
	private string _path;
	
	private Microsoft.SharePoint.Linq.EntityState _entityState;
	
	private System.Collections.Generic.IDictionary<string, object> _originalValues;
	
	private string _title;
	
	#region Extensibility Method Definitions
	partial void OnLoaded();
	partial void OnValidate();
	partial void OnCreated();
	#endregion

	Microsoft.SharePoint.Linq.EntityState Microsoft.SharePoint.Linq.ITrackEntityState.EntityState {
		get {
			return this._entityState;
		}
		set {
			if ((value != this._entityState)) {
				this._entityState = value;
			}
		}
	}

	System.Collections.Generic.IDictionary<string, object> Microsoft.SharePoint.Linq.ITrackOriginalValues.OriginalValues {
		get {
			if ((null == this._originalValues)) {
				this._originalValues = new System.Collections.Generic.Dictionary<string, object>();
			}
			return this._originalValues;
		}
	}
	
	public Item() {
		this.OnCreated();
	}
	
	[Microsoft.SharePoint.Linq.ColumnAttribute(Name="ID", Storage="_id", ReadOnly=true, FieldType="Counter")]
	public System.Nullable<int> Id {
		get {
			return this._id;
		}
		set {
			if ((value != this._id)) {
				this.OnPropertyChanging("Id", this._id);
				this._id = value;
				this.OnPropertyChanged("Id");
			}
		}
	}
	
	[Microsoft.SharePoint.Linq.ColumnAttribute(Name="owshiddenversion", Storage="_version", ReadOnly=true, FieldType="Integer")]
	public System.Nullable<int> Version {
		get {
			return this._version;
		}
		set {
			if ((value != this._version)) {
				this.OnPropertyChanging("Version", this._version);
				this._version = value;
				this.OnPropertyChanged("Version");
			}
		}
	}
	
	[Microsoft.SharePoint.Linq.ColumnAttribute(Name="FileDirRef", Storage="_path", ReadOnly=true, FieldType="Lookup", IsLookupValue=true)]
	public string Path {
		get {
			return this._path;
		}
		set {
			if ((value != this._path)) {
				this.OnPropertyChanging("Path", this._path);
				this._path = value;
				this.OnPropertyChanged("Path");
			}
		}
	}
	
	[Microsoft.SharePoint.Linq.ColumnAttribute(Name="Title", Storage="_title", Required=true, FieldType="Text")]
	public string Title {
		get {
			return this._title;
		}
		set {
			if ((value != this._title)) {
				this.OnPropertyChanging("Title", this._title);
				this._title = value;
				this.OnPropertyChanged("Title");
			}
		}
	}
	
	public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
	
	public event System.ComponentModel.PropertyChangingEventHandler PropertyChanging;
	
	protected virtual void OnPropertyChanged(string propertyName) {
		if ((null != this.PropertyChanged)) {
			this.PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
		}
	}
	
	protected virtual void OnPropertyChanging(string propertyName, object value) {
		if ((null == this._originalValues)) {
			this._originalValues = new System.Collections.Generic.Dictionary<string, object>();
		}
		if ((false == this._originalValues.ContainsKey(propertyName))) {
			this._originalValues.Add(propertyName, value);
		}
		if ((null != this.PropertyChanging)) {
			this.PropertyChanging(this, new System.ComponentModel.PropertyChangingEventArgs(propertyName));
		}
	}
}

/// <summary>
/// Track a work item that you or your team needs to complete.
/// </summary>
[Microsoft.SharePoint.Linq.ContentTypeAttribute(Name="Task", Id="0x0108")]
[Microsoft.SharePoint.Linq.DerivedEntityClassAttribute(Type=typeof(BaseTask))]
public partial class Task : Item {
	
	private System.Nullable<double> _complete;
	
	private string _body;
	
	private System.Nullable<System.DateTime> _startDate;
	
	private System.Nullable<System.DateTime> _dueDate;
	
	private System.Nullable<Priority> _priority;
	
	private System.Nullable<TaskStatus> _taskStatus;
	
	private System.Nullable<int> _assignedToId;
	
	private string _assignedTo;
	
	#region Extensibility Method Definitions
	partial void OnLoaded();
	partial void OnValidate();
	partial void OnCreated();
	#endregion
	
	public Task() {
		this.OnCreated();
	}
	
	[Microsoft.SharePoint.Linq.ColumnAttribute(Name="PercentComplete", Storage="_complete", FieldType="Number")]
	public System.Nullable<double> Complete {
		get {
			return this._complete;
		}
		set {
			if ((value != this._complete)) {
				this.OnPropertyChanging("Complete", this._complete);
				this._complete = value;
				this.OnPropertyChanged("Complete");
			}
		}
	}
	
	[Microsoft.SharePoint.Linq.ColumnAttribute(Name="Body", Storage="_body", FieldType="Note")]
	public string Body {
		get {
			return this._body;
		}
		set {
			if ((value != this._body)) {
				this.OnPropertyChanging("Body", this._body);
				this._body = value;
				this.OnPropertyChanged("Body");
			}
		}
	}
	
	[Microsoft.SharePoint.Linq.ColumnAttribute(Name="StartDate", Storage="_startDate", FieldType="DateTime")]
	public System.Nullable<System.DateTime> StartDate {
		get {
			return this._startDate;
		}
		set {
			if ((value != this._startDate)) {
				this.OnPropertyChanging("StartDate", this._startDate);
				this._startDate = value;
				this.OnPropertyChanged("StartDate");
			}
		}
	}
	
	[Microsoft.SharePoint.Linq.ColumnAttribute(Name="TaskDueDate", Storage="_dueDate", FieldType="DateTime")]
	public System.Nullable<System.DateTime> DueDate {
		get {
			return this._dueDate;
		}
		set {
			if ((value != this._dueDate)) {
				this.OnPropertyChanging("DueDate", this._dueDate);
				this._dueDate = value;
				this.OnPropertyChanged("DueDate");
			}
		}
	}
	
	[Microsoft.SharePoint.Linq.ColumnAttribute(Name="Priority", Storage="_priority", FieldType="Choice")]
	public System.Nullable<Priority> Priority {
		get {
			return this._priority;
		}
		set {
			if ((value != this._priority)) {
				this.OnPropertyChanging("Priority", this._priority);
				this._priority = value;
				this.OnPropertyChanged("Priority");
			}
		}
	}
	
	[Microsoft.SharePoint.Linq.ColumnAttribute(Name="TaskStatus", Storage="_taskStatus", FieldType="Choice")]
	public System.Nullable<TaskStatus> TaskStatus {
		get {
			return this._taskStatus;
		}
		set {
			if ((value != this._taskStatus)) {
				this.OnPropertyChanging("TaskStatus", this._taskStatus);
				this._taskStatus = value;
				this.OnPropertyChanged("TaskStatus");
			}
		}
	}
	
	[Microsoft.SharePoint.Linq.ColumnAttribute(Name="AssignedTo", Storage="_assignedToId", FieldType="User", IsLookupId=true)]
	public System.Nullable<int> AssignedToId {
		get {
			return this._assignedToId;
		}
		set {
			if ((value != this._assignedToId)) {
				this.OnPropertyChanging("AssignedToId", this._assignedToId);
				this._assignedToId = value;
				this.OnPropertyChanged("AssignedToId");
			}
		}
	}
	
	[Microsoft.SharePoint.Linq.ColumnAttribute(Name="AssignedTo", Storage="_assignedTo", ReadOnly=true, FieldType="User", IsLookupValue=true)]
	public string AssignedTo {
		get {
			return this._assignedTo;
		}
		set {
			if ((value != this._assignedTo)) {
				this.OnPropertyChanging("AssignedTo", this._assignedTo);
				this._assignedTo = value;
				this.OnPropertyChanged("AssignedTo");
			}
		}
	}
}

/// <summary>
/// Content type for project tasks
/// </summary>
[Microsoft.SharePoint.Linq.ContentTypeAttribute(Name="Base Task", Id="0x0108002A006A0A30EE489F9002E7391571A9B9")]
[Microsoft.SharePoint.Linq.DerivedEntityClassAttribute(Type=typeof(TasksBaseTask))]
public partial class BaseTask : Task {
	
	private System.Nullable<double> _totalHours;
	
	private System.Nullable<bool> _taskRunning;
	
	private System.Nullable<double> _consumedTime;
	
	private System.Nullable<System.DateTime> _startRealTime;
	
	#region Extensibility Method Definitions
	partial void OnLoaded();
	partial void OnValidate();
	partial void OnCreated();
	#endregion
	
	public BaseTask() {
		this.OnCreated();
	}
	
	[Microsoft.SharePoint.Linq.ColumnAttribute(Name="SP_Total_Hours", Storage="_totalHours", Required=true, FieldType="Number")]
	public System.Nullable<double> TotalHours {
		get {
			return this._totalHours;
		}
		set {
			if ((value != this._totalHours)) {
				this.OnPropertyChanging("TotalHours", this._totalHours);
				this._totalHours = value;
				this.OnPropertyChanged("TotalHours");
			}
		}
	}
	
	[Microsoft.SharePoint.Linq.ColumnAttribute(Name="SP_Task_Running", Storage="_taskRunning", FieldType="Boolean")]
	public System.Nullable<bool> TaskRunning {
		get {
			return this._taskRunning;
		}
		set {
			if ((value != this._taskRunning)) {
				this.OnPropertyChanging("TaskRunning", this._taskRunning);
				this._taskRunning = value;
				this.OnPropertyChanged("TaskRunning");
			}
		}
	}
	
	[Microsoft.SharePoint.Linq.ColumnAttribute(Name="SP_Consumed_Time", Storage="_consumedTime", Required=true, FieldType="Number")]
	public System.Nullable<double> ConsumedTime {
		get {
			return this._consumedTime;
		}
		set {
			if ((value != this._consumedTime)) {
				this.OnPropertyChanging("ConsumedTime", this._consumedTime);
				this._consumedTime = value;
				this.OnPropertyChanged("ConsumedTime");
			}
		}
	}
	
	[Microsoft.SharePoint.Linq.ColumnAttribute(Name="SP_StartTime", Storage="_startRealTime", FieldType="DateTime")]
	public System.Nullable<System.DateTime> StartRealTime {
		get {
			return this._startRealTime;
		}
		set {
			if ((value != this._startRealTime)) {
				this.OnPropertyChanging("StartRealTime", this._startRealTime);
				this._startRealTime = value;
				this.OnPropertyChanged("StartRealTime");
			}
		}
	}
}

/// <summary>
/// Content type for project tasks
/// </summary>
[Microsoft.SharePoint.Linq.ContentTypeAttribute(Name="Base Task", Id="0x0108002A006A0A30EE489F9002E7391571A9B9", List="Tasks")]
public partial class TasksBaseTask : BaseTask {
	
	private Microsoft.SharePoint.Linq.EntitySet<TasksBaseTask> _tasksBaseTask0;
	
	private Microsoft.SharePoint.Linq.EntitySet<TasksBaseTask> _predecessors;
	
	#region Extensibility Method Definitions
	partial void OnLoaded();
	partial void OnValidate();
	partial void OnCreated();
	#endregion
	
	public TasksBaseTask() {
		this._tasksBaseTask0 = new Microsoft.SharePoint.Linq.EntitySet<TasksBaseTask>();
		this._tasksBaseTask0.OnSync += new System.EventHandler<Microsoft.SharePoint.Linq.AssociationChangedEventArgs<TasksBaseTask>>(this.OnTasksBaseTask0Sync);
		this._tasksBaseTask0.OnChanged += new System.EventHandler(this.OnTasksBaseTask0Changed);
		this._tasksBaseTask0.OnChanging += new System.EventHandler(this.OnTasksBaseTask0Changing);
		this._predecessors = new Microsoft.SharePoint.Linq.EntitySet<TasksBaseTask>();
		this._predecessors.OnSync += new System.EventHandler<Microsoft.SharePoint.Linq.AssociationChangedEventArgs<TasksBaseTask>>(this.OnPredecessorsSync);
		this._predecessors.OnChanged += new System.EventHandler(this.OnPredecessorsChanged);
		this._predecessors.OnChanging += new System.EventHandler(this.OnPredecessorsChanging);
		this.OnCreated();
	}
	
	[Microsoft.SharePoint.Linq.AssociationAttribute(Name="Predecessors", Storage="_tasksBaseTask0", ReadOnly=true, MultivalueType=Microsoft.SharePoint.Linq.AssociationType.Backward, List="Tasks")]
	public Microsoft.SharePoint.Linq.EntitySet<TasksBaseTask> TasksBaseTask0 {
		get {
			return this._tasksBaseTask0;
		}
		set {
			this._tasksBaseTask0.Assign(value);
		}
	}
	
	[Microsoft.SharePoint.Linq.AssociationAttribute(Name="Predecessors", Storage="_predecessors", MultivalueType=Microsoft.SharePoint.Linq.AssociationType.Multi, List="Tasks")]
	public Microsoft.SharePoint.Linq.EntitySet<TasksBaseTask> Predecessors {
		get {
			return this._predecessors;
		}
		set {
			this._predecessors.Assign(value);
		}
	}
	
	private void OnTasksBaseTask0Changing(object sender, System.EventArgs e) {
		this.OnPropertyChanging("TasksBaseTask0", this._tasksBaseTask0.Clone());
	}
	
	private void OnTasksBaseTask0Changed(object sender, System.EventArgs e) {
		this.OnPropertyChanged("TasksBaseTask0");
	}
	
	private void OnTasksBaseTask0Sync(object sender, Microsoft.SharePoint.Linq.AssociationChangedEventArgs<TasksBaseTask> e) {
		if ((Microsoft.SharePoint.Linq.AssociationChangedState.Added == e.State)) {
			e.Item.Predecessors.Add(this);
		}
		else {
			e.Item.Predecessors.Remove(this);
		}
	}
	
	private void OnPredecessorsChanging(object sender, System.EventArgs e) {
		this.OnPropertyChanging("Predecessors", this._predecessors.Clone());
	}
	
	private void OnPredecessorsChanged(object sender, System.EventArgs e) {
		this.OnPropertyChanged("Predecessors");
	}
	
	private void OnPredecessorsSync(object sender, Microsoft.SharePoint.Linq.AssociationChangedEventArgs<TasksBaseTask> e) {
		if ((Microsoft.SharePoint.Linq.AssociationChangedState.Added == e.State)) {
			e.Item.TasksBaseTask0.Add(this);
		}
		else {
			e.Item.TasksBaseTask0.Remove(this);
		}
	}
}

public enum Priority : int {
	
	None = 0,
	
	Invalid = 1,
	
	[Microsoft.SharePoint.Linq.ChoiceAttribute(Value="(1) High")]
	_1High = 2,
	
	[Microsoft.SharePoint.Linq.ChoiceAttribute(Value="(2) Normal")]
	_2Normal = 4,
	
	[Microsoft.SharePoint.Linq.ChoiceAttribute(Value="(3) Low")]
	_3Low = 8,
}

public enum TaskStatus : int {
	
	None = 0,
	
	Invalid = 1,
	
	[Microsoft.SharePoint.Linq.ChoiceAttribute(Value="Not Started")]
	NotStarted = 2,
	
	[Microsoft.SharePoint.Linq.ChoiceAttribute(Value="In Progress")]
	InProgress = 4,
	
	[Microsoft.SharePoint.Linq.ChoiceAttribute(Value="Completed")]
	Completed = 8,
	
	[Microsoft.SharePoint.Linq.ChoiceAttribute(Value="Deferred")]
	Deferred = 16,
	
	[Microsoft.SharePoint.Linq.ChoiceAttribute(Value="Waiting on someone else")]
	WaitingOnSomeoneElse = 32,
}
}